package websql;
import java.sql.ResultSet;


public class Conn {
	public static String[] getConnNames() throws Exception{
		String sql="select cname from conn";
		ResultSet rs=DBcon.getConn().createStatement().executeQuery(sql);
		rs.last();
		String cname[]=new String[rs.getRow()];
		rs.beforeFirst();
		while(rs.next()){
			String tmp=rs.getString("cname");
				tmp=unit.EscapeUnescape.unescape(tmp);
			cname[rs.getRow()-1]=tmp;
		}
		return cname;
	}
	public static int getcid(String what,String iswhat) throws Exception{
		String sql="select cid from conn where "+what+" = '"+iswhat+"'";
		ResultSet rs=DBcon.getConn().createStatement().executeQuery(sql);
		rs.next();
		int cid=rs.getInt("cid");
		return cid;
	}
	
	public static String get(String what ,int whichcid) throws Exception{
		String sql="select "+what+" from conn where cid = '"+whichcid+"'";
		ResultSet rs=DBcon.getConn().createStatement().executeQuery(sql);
		rs.next();
		String ans=unit.EscapeUnescape.unescape(rs.getString(what));
		return ans;
	}

}
